package com.meilele.biz.czh;

import com.meilele.dao.czh.FiveCompanyMapper;
import com.meilele.dao.czh.FiveDesignMapper;
import com.meilele.entity.czh.FiveCompany;
import com.meilele.util.czh.Constants;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CompanyBiz {
    @Resource
    private FiveCompanyMapper fiveCompanyMapper;
    @Resource
    private FiveDesignMapper fiveDesignMapper;

    public List<FiveCompany> selectFiveCompanyCity(String companycity,int pageNum){
        int firstPage=(pageNum-1)* Constants.PAGE_SIZE;
        return fiveCompanyMapper.selectByPrimaryCity(companycity,firstPage,Constants.PAGE_SIZE);
    }
    public FiveCompany selectFiveCompanykey(int companyId){
        return fiveCompanyMapper.selectByPrimaryKey(companyId);
    }
    public void save(FiveCompany fiveCompany){
        fiveCompanyMapper.insert(fiveCompany);
    }
    public int findCount(String CityName){
        return fiveCompanyMapper.selectByPrimaryCount(CityName);
    }
    public List<FiveCompany> findAll(int pageNum){
        int firstPage=(pageNum-1)* Constants.PAGE_SIZ;
        return fiveCompanyMapper.findAll(firstPage,Constants.PAGE_SIZ);
    }
    public int findcon(){
        return fiveCompanyMapper.findcon();
    }
    public FiveCompany findId(int companyId){
        return fiveCompanyMapper.selectByPrimaryKey(companyId);
    }
    public void updateCompany(FiveCompany fiveCompany){
        fiveCompanyMapper.updateByPrimaryKey(fiveCompany);
    }

    public List<FiveCompany> findAllcom(){
        return fiveCompanyMapper.findAllcom();
    }

   public void deleteCompany(int companyId){
        fiveCompanyMapper.deleteByPrimaryKey(companyId);
        fiveDesignMapper.deleteByPrimarycompanyId(companyId);

   }
}
